package com.aiwhose.aiwhosecore.bean.security.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 用户表 表定义层。
 *
 * @author 田国刚
 * @since 1.0.1
 */
public class UserTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户表
     */
    public static final UserTableDef USER = new UserTableDef();

    
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 头像
     */
    public final QueryColumn IMG = new QueryColumn(this, "img");

    /**
     * 性别
     */
    public final QueryColumn SEX = new QueryColumn(this, "sex");

    /**
     * 姓名
     */
    public final QueryColumn NAME = new QueryColumn(this, "name");

    /**
     * 盐值
     */
    public final QueryColumn SALT = new QueryColumn(this, "salt");

    /**
     * 邮箱
     */
    public final QueryColumn EMAIL = new QueryColumn(this, "email");

    /**
     * 手机号
     */
    public final QueryColumn PHONE = new QueryColumn(this, "phone");

    /**
     * 状态 0 启用
     */
    public final QueryColumn STATE = new QueryColumn(this, "state");

    /**
     * 人脸库
     */
    public final QueryColumn FACE_ID = new QueryColumn(this, "face_id");

    /**
     * 删除
     */
    public final QueryColumn DELETED = new QueryColumn(this, "deleted");

    /**
     * 唯一 ID
     */
    public final QueryColumn UNIONID = new QueryColumn(this, "unionid");

    /**
     * 创建人
     */
    public final QueryColumn CREATE_BY = new QueryColumn(this, "create_by");

    /**
     * 昵称
     */
    public final QueryColumn NICK_NAME = new QueryColumn(this, "nick_name");

    /**
     * 密码
     */
    public final QueryColumn PASSWORD = new QueryColumn(this, "password");

    /**
     * 更新者
     */
    public final QueryColumn UPDATE_BY = new QueryColumn(this, "update_by");

    /**
     * openID
     */
    public final QueryColumn WX_OPEN_ID = new QueryColumn(this, "wx_open_id");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 系统类别
     */
    public final QueryColumn SYSTEM_TYPE = new QueryColumn(this, "system_type");

    /**
     * 更新时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, PHONE, PASSWORD, WX_OPEN_ID, UNIONID, SYSTEM_TYPE, FACE_ID, SALT, NAME, SEX, IMG, NICK_NAME, STATE, EMAIL, CREATE_TIME, CREATE_BY, UPDATE_TIME, UPDATE_BY, };

    public UserTableDef() {
        super("", "user");
    }

    private UserTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public UserTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new UserTableDef("", "user", alias));
    }

}
